Xbasic

SQL::ConnectionToGridComponentDataObject Method

Syntax

Result_Flag as L = ToGridComponentDataObject(SQLStatement as C, [Arguments as SQL::Arguments,] DataArray as p[], FieldArray as p[] [, RowsToCopy = -1 as N [, StartRow = 1 as N ]])

Arguments

SQLStatementCharacter

A SQL SELECT statement.

ArgumentsSQL::Arguments

A SQL::Arguments object. One or more arguments to be resolved when the SELECT statement is executed.

DataArrayP[]

Pointer array. The DataArray argument will be initialized with current values.

FieldArrayP[]

Pointer array. The FieldArray argument will contain field information.

RowsToCopyNumeric

Default = -1 (all). The number of rows to copy.

StartRowNumeric

Default = 1 (first). The first row to copy.

Returns

Result_FlagLogical

TRUE (.T.) if the operation was successful; otherwise FALSE (.F.).

Description

Fetch data to a Grid Component Data Object using a SQL Query.

You must dim the arrays first: DIM MyArray[1] as P

The ToGridComponentDataObject() method fetches data in a format suitable for a grid component using. Note: You must dim the arrays first.

Example

dim DataArray[0] as P
dim FieldArray[0] as P
dim conn as SQL::Connection
dim cs as C
dim str as C
cs = "{A5API=Access, FileName='C:\Program Files\A5V8\MDBFiles\Alphasports.mdb', UserName='Admin'}"
if .not. conn.open(cs) then
    ui_msg_box("Error", conn.CallResult.text)
    end
end if
if .not. conn.ToGridComponentDataObject("select * from customer", DataArray, FieldArray) then
    ui_msg_box("Error", conn.CallResult.text)
    conn.close()
    end
end if
str = property_to_string(dataarray)
showvar(str)
conn.close()

The str variable's contents look like this.

1data1initial=1>
current=1>
IsNull=.F.>
>
2TEXT="">
initial="Michael">
current="Michael">
IsNull=.F.>
>
3TEXT="">
initial="Graham">
current="Graham">
IsNull=.F.>
>
...

See Also